<template>
	<el-dialog v-model="dialogVisible" append-to-body :show-close="false" :close-on-click-modal="false"
		class="flex-align" style="width: 100%;height: 100%;padding: 30px 24px;margin: 0;background: transparent;">
		<template #header>
			<el-card style="width: 100%;height: 100%;" body-style="padding: 0;" shadow="never">
				<template #header>
					<div class="flex-space-between">
						<div>
							<el-text style="font-size: 16px;">
								出库单
							</el-text>
						</div>
						<div>
							<el-button @click="closeDialog">取消</el-button>
							<!-- 							<el-button @click="closeDialog">
								保存并继续创建
								<el-icon style="margin-left: 4px;">
									<ArrowDown />
								</el-icon>
							</el-button> -->
							<el-button type="primary" @click="submitForm(vFormRef)">
								保存
							</el-button>
						</div>
					</div>
				</template>
				<el-scrollbar :style="`height: calc(100vh - 69px - ( 30px + 30px));`">
					<el-form :model="formData" ref="vFormRef" :rules="rules" label-position="top" label-width="50px"
						style="padding: 16px;">
						<el-row :gutter="16">
							<el-col :span="!formData.outboundTypeId?24:formData.outboundTypeId===174?24:12">
								<el-form-item label="出库单号" prop="outboundNumber" class="form-item-bg">
									<el-input type="text" v-model="formData.outboundNumber" placeholder="自动生成无需填写"
										readonly clearable></el-input>
								</el-form-item>
							</el-col>
							<!-- 发货单 -->
							<el-col :span="formData.outboundTypeId===175?12:0">
								<el-form-item label="发货单" prop="deliveryOrder" class="form-item-bg">
									<el-select @clear="selectClear('deliveryOrder')" v-model="formData.deliveryOrder"
										@change="(value:any)=>selectChange(value,'deliveryOrder')" multiple
										ref="deliveryOrder" clearable>
										<el-option v-for="item in deliveryOrderOption" :key="key" :label="item?.label"
											:value="item?.value">
											<!--  -->
											<div class="flex-align-center">
												<el-icon :color="item?.color">
													<component :is="item?.icon"></component>
												</el-icon>
												<!--  -->
												<el-text style="margin-left: 6px;">{{item?.label}}</el-text>
											</div>
										</el-option>
										<!--  -->
										<template #tag>
											<div style="padding-left: 6px;">
												<div>
													<div class="flex-align-center">
														<el-icon
															:color="deliveryOrderOption[deliveryOrderIndex]?.color">
															<component
																:is="deliveryOrderOption[deliveryOrderIndex]?.icon">
															</component>
														</el-icon>
														<!--  -->
														<el-text size="small"
															style="margin-left: 6px;">{{deliveryOrderOption[deliveryOrderIndex]?.label}}</el-text>
													</div>
												</div>
											</div>
										</template>
									</el-select>
								</el-form-item>
							</el-col>
							<!-- 退货订单 -->
							<el-col :span="formData.outboundTypeId===176?12:0">
								<el-form-item label="退货订单" prop="return" class="form-item-bg">
									<el-input readonly type="text" placeholder="还没写" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<!--  -->
						<el-row :gutter="16">
							<el-col :span="12">
								<!--  -->
								<el-form-item label="出库状态" prop="outboundStatusId" class="form-item-bg">
									<el-input readonly type="text" v-model="formData.outboundStatusId" clearable
										class="my">
										<template #prefix>
											<div>
												<el-check-tag
													:style="`color: ${outboundStatusIndex===key?'#fff':''};${outboundStatusIndex===key?`background: ${item.bg}`:''}`"
													v-for="(item,key) in outboundStatusTags" :key="key"
													:checked="outboundStatusIndex===key"
													@change="tagChange(key,'outboundStatusId')">{{item.text}}</el-check-tag>
											</div>
										</template>
									</el-input>
								</el-form-item>
								<!--  -->
							</el-col>
							<el-col :span="12">
								<!--  -->
								<el-form-item label="出库类型" prop="outboundType" class="form-item-bg">
									<el-select @clear="selectClear('outboundType')" v-model="formData.outboundType"
										@change="(value:any)=>selectChange(value,'outboundType')" multiple
										ref="outboundType" clearable>
										<el-option v-for="(item, key) in outboundTypeOption" :key="key"
											:label="item?.label" :value="item?.value">
											<!--  -->
											<el-tag style="border: 0;" :color="item?.color" round effect="dark">
												{{ item?.label }}
											</el-tag>
											<!--  -->
										</el-option>
										<!--  -->
										<template #tag>
											<el-tag style="border: 0;"
												v-if="outboundTypeOption[outboundTypeIndex]?.value"
												:color="outboundTypeOption[outboundTypeIndex]?.color" round
												effect="dark">
												{{ outboundTypeOption[outboundTypeIndex]?.label }}
											</el-tag>
										</template>
									</el-select>
								</el-form-item>
								<!--  -->
							</el-col>
						</el-row>
						<div class="static-content-item">
							<div>出库信息</div>
						</div>
						<el-row :gutter="16">
							<el-col :span="12">
								<!--  -->
								<el-form-item label="申请人" prop="applicant">
									<el-input type="text" readonly v-model="formData.applicant" clearable></el-input>
								</el-form-item>
								<!--  -->
							</el-col>
							<el-col :span="12">
								<!--  -->
								<el-form-item label="申请日期" prop="applicationDate">
									<el-date-picker v-model="formData.applicationDate" style="width:100%;"
										type="date" />
								</el-form-item>
								<!--  -->
							</el-col>
						</el-row>
						<!--  -->
						<el-form-item label="出库总量" prop="totalQuantity">
							<el-input type="text" v-model="formData.totalQuantity" readonly placeholder="自动计算结果"
								clearable></el-input>
						</el-form-item>
						<!--  -->
						<div class="static-content-item">
							<div>出库审核</div>
						</div>
						<el-row :gutter="16">
							<el-col :span="12">
								<!--  -->
								<el-form-item label="审批人" prop="approver" class="form-item-bg1">
									<el-input type="text" readonly v-model="formData.approver" clearable></el-input>
								</el-form-item>
								<!--  -->
							</el-col>
							<el-col :span="12">
								<!--  -->
								<el-form-item label="出库日期" prop="outboundDate" class="form-item-bg1">
									<el-date-picker v-model="formData.outboundDate" style="width:100%;" type="date" />
								</el-form-item>
								<!--  -->
							</el-col>
						</el-row>
						<!--  -->
						<el-form-item label="出库拍照" prop="outboundPhoto">
							<el-input readonly clearable>
								<template #prefix>
									<el-upload v-model:file-list="formData.files" action="/api/oss/policy"
										:on-success="onSuccess" :headers="{'Authorization':cookie.get('token')}"
										:limit="1">
										<el-button v-if="!formData.outboundPhoto" text :icon="UploadFilled">
											上传图片
										</el-button>
										<el-image v-else preview-teleported
											style="width: 30px; height: 30px;margin: 10px auto;"
											:src="formData.outboundPhoto"
											:preview-src-list="[formData.outboundPhoto]" />
									</el-upload>
								</template>
							</el-input>
						</el-form-item>
						<!--  -->
						<el-form-item label="备注" prop="remark">
							<el-input type="text" v-model="formData.remark" clearable></el-input>
						</el-form-item>
						<!--  -->
						<el-form-item>
							<el-input type="text" ref="salesPerson" readonly clearable class="my1">
								<template #prefix>
									<div style="margin: 0;padding: 0;">
										<el-tabs v-model="activeName" @tab-click="handleClick" class="my">
											<el-tab-pane label="出库明细" name="order">
												<div class="flex-space-between"
													style="height: 48px;padding-left: 10px;">
													<el-text type="info" size="small">
														来自 <el-text type="primary" size="small">出库明细</el-text> 的数据
														共{{formData.tableData.length}}条
													</el-text>
													<el-text>
														<el-tooltip effect="light" :hide-after="50" content="创建"
															placement="top">
															<div class="my-a" @click="setTableData">
																<el-icon size="16px" color="#409EFF">
																	<CirclePlus />
																</el-icon>
															</div>
														</el-tooltip>
													</el-text>
												</div>
												<!--  -->
												<el-scrollbar style="width: calc(100vw - 48px - 32px);height: 300px;">
													<el-table @cell-dblclick="tableCellClick" v-loading="loading"
														:data="formData.tableData" :stripe="false" table-layout="auto"
														:default-sort="{}" border style="width: 100%;height: 300px;"
														class="my">
														<el-table-column width="76" fixed="left" prop="id"
															:sortable="false">
															<template #default="scope">
																<el-tooltip effect="light" :hide-after="50" content="复制"
																	placement="top">
																	<el-button style="padding: 0;" class="my"
																		@click="copyTableData(scope.$index)"
																		:icon="DocumentAdd"></el-button>
																</el-tooltip>
																<el-tooltip effect="light" :hide-after="50" content="删除"
																	placement="top">
																	<el-button style="padding: 0;" class="my"
																		@click="deleteTableData(scope.$index)"
																		:icon="Delete"></el-button>
																</el-tooltip>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="productId" label="出库产品*(可选)"
															:sortable="false">
															<template #default="scope">
																<el-form-item v-if="!scope.row.productId" class="my"
																	:prop="`tableData[${scope.$index}].productId`"
																	:rules="[{required: true,message: '出库产品必选',trigger: 'change'}]">
																	<el-input type="number" class="my-s"
																		v-model="scope.row.productId" clearable
																		readonly></el-input>
																</el-form-item>
																<el-text v-else>
																	<div class="flex-align-center"
																		v-if="scope.row?.products">
																		<el-icon :color="scope.row?.products.color">
																			<component :is="scope.row?.products.icon">
																			</component>
																		</el-icon>
																		<el-text size="small" style="margin-left: 6px;">
																			{{scope.row?.products.label}}
																		</el-text>
																	</div>
																</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="unitId" label="单位"
															:sortable="false">
														</el-table-column>
														<el-table-column width="140" prop="currentInventory"
															label="当前库存数量" :sortable="false">
														</el-table-column>
														<el-table-column width="140" prop="outboundQuantity"
															label="出库数量*(可选)" :sortable="false">
															<template #default="scope">
																<el-form-item v-if="!scope.row.outboundQuantity"
																	class="my"
																	:prop="`tableData[${scope.$index}].outboundQuantity`"
																	:rules="[{required: true,message: '出库数量必填',trigger: 'change'}]">
																	<el-input type="number" class="my-s"
																		v-model="scope.row.outboundQuantity" clearable
																		readonly></el-input>
																</el-form-item>
																<el-text v-else>{{scope.row.outboundQuantity}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="notes" label="备注*(可选)">
														</el-table-column>
													</el-table>
												</el-scrollbar>
											</el-tab-pane>
										</el-tabs>
									</div>
								</template>
							</el-input>
						</el-form-item>

					</el-form>
				</el-scrollbar>
				<!--  -->
			</el-card>
			<!--  -->
			<levitation ref="levitationRef" :option="selectCell.option" :types="types" :st_type="selectCell.type"
				:params="levitationParams" :observerElement="scrollbarRef" :element="element" @change="levitationChange"
				@blur="levitationBlur" />
		</template>
	</el-dialog>
</template>

<script setup lang="ts">
	import { reactive, ref } from 'vue';
	import { useRoute, useRouter } from 'vue-router';
	import request from '../../../utils/request';
	import { Check, UserFilled, GoodsFilled, WalletFilled, CirclePlus, DocumentAdd, Delete, UploadFilled } from '@element-plus/icons-vue';
	import { mergeObjects, formatNumber, findIndexByLabel } from '../../../utils';
	import { formatDate } from '../../../utils/date';
	import { useSelect } from '../../../utils/mixins';
	import levitation from '../../../components/levitation-form/levitation-form.vue';
	import { getShipments } from '../../../api/shipmentAPI';
	import { ElMessage, FormInstance } from 'element-plus';
	import { jwtDecode } from 'jwt-decode';
	import cookie from 'js-cookie';
	const emits = defineEmits(['update']);
	const { handSelectChange } = useSelect();
	const router = useRouter();
	const route = useRoute();
	const vFormRef = ref(null);
	const loading = ref(false);
	const activeName = ref('order');
	//levitation start
	const element = ref(null);
	const levitationRef = ref(null);
	const scrollbarRef = ref(null);
	const types = ref('');
	const selectCell = ref({
		id: 0,
		property: '',
		type: '',
		option: []
	});
	const levitationParams = ref(null);
	//levitation end

	// 表单
	const formData = ref({
		outboundNumber: null,//出库单号
		deliveryOrderId: null,//发货单
		deliveryOrder: [],
		outboundStatusId: null,//出库状态
		outboundStatus: [],
		outboundTypeId: null,//出库类型
		outboundType: [],
		applicant: null,//申请人
		applicationDate: null,//申请日期
		totalQuantity: null,//出库总量
		approver: null,//审核人
		outboundDate: null,//出库日期
		outboundPhoto: null,//出库拍照
		files: [],//文件
		remark: null,//备注
		productId: null,//出库商品
		product: [],
		purchaseReturnOrderId: null,//采购退货单
		purchaseReturnOrder: [],
		approvalTime: null,//审批时间
		tableData: []
	});
	//验证
	const rules = reactive({
		outboundNumber: [],//出库单号
		deliveryOrderId: [],//发货单
		outboundStatusId: [{ required: true, message: '不能为空', trigger: 'blur' }],//出库状态
		outboundType: [{ required: true, message: '不能为空', trigger: 'blur' }],//出库类型
		applicant: [{ required: true, message: '不能为空', trigger: 'blur' }],//申请人
		applicationDate: [{ required: true, message: '不能为空', trigger: 'blur' }],//申请日期
		totalQuantity: [{ required: true, message: '不能为空', trigger: 'blur' }],//出库总量
		approver: [{ required: true, message: '不能为空', trigger: 'blur' }],//审核人
		outboundDate: [{ required: true, message: '不能为空', trigger: 'blur' }],//出库日期
		outboundPhoto: [],//出库拍照
		remark: [],//备注
		product: [],//出库商品
		purchaseReturnOrder: [],//采购退货单
		approvalTime: [],//审批时间
	});
	const pageData = ref({
		pageNum: 1,
		pageSize: 1000,
		total: 0,
		pages: 0,
	});
	//发货单
	const deliveryOrderOption = ref([]);
	const deliveryOrderIndex = ref(-1);
	const deliveryOrder = ref(null);
	//出库状态 tag
	const outboundStatusTags = ref([]);
	const outboundStatusIndex = ref(-1);
	//出库类型
	const outboundTypeOption = ref([]);
	const outboundTypeIndex = ref(-1);
	const outboundType = ref(null);
	//出库产品
	const productOption = ref([]);
	const productIndex = ref(-1);
	const product = ref(null);
	//tag改变
	const tagChange = (index : number, type : string) => {
		// if (type === 'outboundStatusId') {
		// 	if (outboundStatusIndex.value === index) {
		// 		formData.value[type] = 0;
		// 		outboundStatusIndex.value = -1;
		// 		return;
		// 	}
		// 	outboundStatusIndex.value = index;
		// 	formData.value[type] = outboundStatusTags.value[index].value;
		// }
	}
	//
	const dialogVisible = ref(false);
	/**
	 * 打开弹出层
	 */
	const openDialog = () => {
		dialogVisible.value = true;
		setTimeout(async () => {
			const result = await getPageId();
			//
			if (result) {
				getOutboundStatus();
				getOutboundType();
				getDeliveryOrder();
				if (!route.query.id) {
					outboundStatusIndex.value = 0;
					formData.value.outboundStatusId = 170;
				}
			}
		}, 10);
	}
	/**
	 * 关闭弹出层
	 */
	const closeDialog = () => {
		dialogVisible.value = false;
		vFormRef.value.resetFields();
		//清空url参数
		router.push({ query: {} });
	}
	//获取当前页面的数据
	const getPageId = async () => {
		if (!route.query.id) {
			const token = cookie.get('token');
			const decodedToken : {
				username : string
			} = jwtDecode(token);
			// console.log('decodedToken--->', decodedToken);
			//
			formData.value.applicant = decodedToken?.username;
			formData.value.approver = decodedToken?.username;
			//
			return true;
		}
		//
		const result = await request({
			url: '/demand/selectOutboundOrderById',
			params: {
				id: route.query.id
			},
		});
		//
		console.log('getPageId --->', result);
		//
		formData.value = { ...result.data.t };
		formData.value.tableData = [...result.data.t.outboundDetailList];
		//
		formData.value.tableData.forEach((item : any, key : number) => {
			getProductById(item.productId, key);
		})
		return true;
	}
	//改变
	const selectChange = (value : Array<any>, type : string, key : number) => {
		//所有下拉框的配置列表
		const typeList = [{
			type: 'outboundType', //哪一个下拉框，根据ref
			option: outboundTypeOption, //下拉列表选项
			indexVar: outboundTypeIndex, //当前选中项
			idVar: 'outboundTypeId', //当前id值
			blurRef: outboundType, //ref
		}, {
			type: 'deliveryOrder', //哪一个下拉框，根据ref
			option: deliveryOrderOption, //下拉列表选项
			indexVar: deliveryOrderIndex, //当前选中项
			idVar: 'deliveryOrderId', //当前id值
			blurRef: deliveryOrder, //ref
			fun: getShipmentDeliveryAll
		},];
		//
		handSelectChange(formData, typeList, value, type, key);
	}

	//设置一个
	const setTableData = () => {
		formData.value.tableData.push({
			id: +new Date(),
			productId: null,//出库产品
			unitId: null, //单位
			currentInventory: null,//当前库存数量
			outboundQuantity: null,//出库数量
			outboundPrice: null,//出库单价
			notes: null,//备注
			deliveryId: null,//发货单id
			orderId: null,//订单id
		});
		//
	}
	//复制一个
	const copyTableData = (index : number) => {
		//...
		const item = { ...formData.value.tableData[index] };
		item.id = +new Date();
		formData.value.tableData.push(item);
		//
	}
	//删除一个
	const deleteTableData = (index : number) => {
		formData.value.tableData.splice(index, 1);
	}
	const tableCellClick = (row : any, column : any, cell : HTMLTableCellElement, event : Event) => {
		types.value = '';
		//出库产品
		if (column.property === 'productId') {
			types.value = 'select-icon';
			selectCell.value.option = [...productOption.value];
		}
		//出库数量
		if (column.property === 'outboundQuantity') {
			types.value = 'number';
		}
		//备注
		if (column.property === 'notes') {
			types.value = 'text';
		}
		element.value = cell;
		//
		selectCell.value.id = row.id;
		selectCell.value.property = column.property;
		//
		levitationParams.value = row[column.property];

		setTimeout(() => {
			levitationRef.value.getElementInfo();
		}, 1);
		//
	}
	//获取出库状态
	const getOutboundStatus = async () => {
		const data = await getShipments('outbound_status', 'tag');
		outboundStatusTags.value = [];
		data.forEach((item : any, key : number) => {
			outboundStatusTags.value.push(item);
			if (formData.value.outboundStatusId === item.value) {
				outboundStatusIndex.value = key;
			}
		});
	}
	//获取出库类型
	const getOutboundType = async () => {
		const data = await getShipments('outbound_type');
		outboundTypeOption.value = [];
		data.forEach((item : any, key : number) => {
			outboundTypeOption.value.push(item);
			if (formData.value.outboundTypeId === item.value) {
				formData.value.outboundType = [item.value];
				outboundTypeIndex.value = key;
			}
		});
	}
	//获取发货单
	const getDeliveryOrder = async () => {
		const result = await request({
			url: '/login/selectDeliveryOrderAll',
			params: { shipmentStatusId: 122 }
		});
		//
		console.log('getDeliveryOrder --->', result);
		deliveryOrderOption.value = [];
		result.data.t.list.forEach((item : any, key : number) => {
			deliveryOrderOption.value.push({
				label: `申请${formatDate(item.applyDeliveryDate)} 发货 | ${item.customer.customerName}`,
				value: item.deliveryId,
				icon: Check,
				color: '#42b33e',
			});
			if (formData.value.deliveryOrderId === item.deliveryId) {
				formData.value.deliveryOrder = [item.deliveryId];
				deliveryOrderIndex.value = key;
				getShipmentDeliveryAll(item.deliveryId);

			}
		});
	}
	//根据id获取商品信息
	const getProductById = async (id : number, key : number, item1 ?: any) => {
		const result = await request({
			url: '/demand/selectProductByPId',
			params: {
				id
			}
		});
		const data = result.data.t;
		formData.value.tableData[key].unitId = data.unitId;
		formData.value.tableData[key].currentInventory = data.currentInventory;
		formData.value.tableData[key].productId = result.data.t.productId;
		formData.value.tableData[key].deliveryId = item1.deliveryId;
		formData.value.tableData[key].orderId = item1.orderId;
		formData.value.tableData[key].products = {
			label: `${result.data.t.productName}${result.data.t.model} | 在库${result.data.t.currentInventory}件`,
			value: result.data.t.productId,
			icon: GoodsFilled,
			color: '#5283ff'
		}
	}
	//根据发货单id获取发货明细的产品
	const getShipmentDeliveryAll = async (id : number) => {
		const result = await request({
			url: '/login/selectShipmentDeliveryAll',
			params: { id }
		});
		//
		console.log('getShipmentDeliveryAll --->', result);
		productOption.value = [];
		result.data.t.list.forEach((item : any, key : number) => {
			productOption.value.push({
				label: `${item.product.productName}${item.product.model} | 在库${item.product.currentInventory}件`,
				value: item.shipmentDetailId,
				icon: GoodsFilled,
				color: '#5283ff',
				productId: item.product.productId,
				//
				deliveryId: item.deliveryOrder.deliveryId,
				orderId: item.orderDetail.salesOrderId,
			});
		});
	}
	//提交表单
	const submitForm = async (formEl : FormInstance | undefined) => {
		if (!formEl) return;
		await formEl.validate(async (valid, fields) => {
			if (valid) {
				let type = '';
				if (!route.query.id) {
					type = '/addOutboundOrder';
				} else {
					type = '/updateOutboundOrder';
				}
				const data = { ...formData.value, outboundDetailList: [...formData.value.tableData] };
				delete data.deliveryOrder;
				delete data.outboundStatus;
				delete data.outboundType;
				delete data.product;
				delete data.purchaseReturnOrder;
				//
				const result = await request({
					url: '/demand' + type,
					data: data,
					method: 'post'
				});
				//
				console.log('submitForm--->', result);
				//
				if (result.data.code === 200) {
					ElMessage.success({
						message: '操作成功！'
					});
					if (!route.query.id) {
						router.push({ query: { id: result.data.t } });
						route.query.id = result.data.t;
						//修改发货单、订单状态
						console.log('data.outboundDetailList --->', data.outboundDetailList);
						data.outboundDetailList.forEach((item : any, key : number) => {
							request({
								url: '/login/selectDeliveryOrderById',
								params: {
									id: item.deliveryId
								},
							}).then((result1) => {
								const item1 = result1.data.t;
								if (item1.shipmentStatusId === 122) {
									item1.shipmentStatusId = 123;
									//修改发货单状态
									request({
										url: '/login/updateDeliveryOrder',
										method: 'post',
										data: item1,
									}).then((results : any) => {
										console.log('updateDeliveryOrder --->', results);
									});
								}
							});
							//修改订单状态
							request({
								url: '/login/selectSaleOrder',
								params: {
									id: item.orderId
								},
							}).then((result1) => {
								const item1 = result1.data.t;
								if (item1.orderStatusId === 112) {
									item1.orderStatusId = 114;
									request({
										url: '/login/updateSaleOrder',
										method: 'post',
										data: item1,
									}).then((results : any) => {
										console.log('updateSaleOrder --->', results);
									});
								}
							});
						});
					}
				} else {
					ElMessage.error({
						message: result.data.msg
					});
				}
				//
				setTimeout(() => {
					closeDialog();
					emits('update');
				}, 1);
			} else {
				//
				console.log('error submit!', fields);
			}
		});
	}
	//失去焦点 ***** 重要！重要！重要！
	const levitationBlur = () => {
		element.value = null;
	}
	//内容改变
	const levitationChange = (value : string | number) => {
		// console.log('value --->', value);
		formData.value.tableData.forEach((item : any, key : number) => {
			// console.log('item.id --->', item.id, 'selectCell.value.id --->', selectCell.value.id);
			if (item.id === selectCell.value.id) {
				item[selectCell.value.property] = value;
				if (selectCell.value.property === 'productId') {
					const index = findIndexByLabel(productOption.value, value, 'value');
					console.log('index --->', index);
					const item1 = productOption.value[index];
					const productId = item1.productId;
					console.log('productId --->', productId);
					getProductById(productId, key, item1);
				}
				if (selectCell.value.property === 'outboundQuantity') {
					computeAll();
				}
			}
		});
	}
	//滚动
	const handleScroll = (e : any) => {
		// console.log('handleScroll --->', e);
		if (element.value === null) return;
		levitationRef.value.getElementInfo();
	}
	//
	const computeAll = () => {
		formData.value.totalQuantity = 0;
		formData.value.tableData.forEach((item : any, key : number) => {
			//出库总量
			formData.value.totalQuantity += Number(item.outboundQuantity);
		});
	}
	//图片上传成功
	const onSuccess = (res : any) => {
		console.log('onSuccess --->', res);
		//
		formData.value.outboundPhoto = res.t;
	}
	//暴露属性和方法给外部使用
	defineExpose({
		openDialog
	});
</script>
<style>
	@import '../../../assets/css/my-form-item.css';

	.el-scrollbar__view {
		display: block !important;
	}

	.form-item-bg {
		background-color: #bfdfff;
	}

	.form-item-bg1 {
		background-color: #a5f2e5;
	}

	.form-item-bg1 {
		background-color: #a5f2e5;
	}

	.el-upload-list--text {
		display: none;
	}
</style>

<style scoped lang="scss">
	@import '../../../assets/css/index.scss';
</style>